using System;
using System.Collections.Generic;
using ProtoModels;
using UnityEngine;

public class LeaderboardsLayer : MonoBehaviour
{
	public enum DataProvider
	{
		NonSegmented = 0,
		Segmented = 1,
		Test = 2
	}

	public List<Color> colorsForPrizes = new List<Color>();

	public DataProvider dataProvider;

	public GameObject leadItemPrefab;

	public GameObject tabPrefab;

	public GameObject emptyEntryPrefab;

	public GameObject playerEntryEmptyPrefab;

	public GameObject prizeItemPrefab;

	public GameObject prizesGameObject;

	public int numItems = 10;

	public UITable tabTable;

	public UITable leadTable;

	public LeaderboardEntry playerEntry;

	public UILabel prizeFirst;

	public UILabel prizeSecond;

	public UILabel prizeThird;

	public UISprite WinCurrency;

	public UILabel timerLabel;

	public UILabel leagueNameLabel;

	public UIScrollView tabView;

	public UIScrollView leadView;

	public GameObject leadEntryObject;

	public GameObject leadEntryUnavailableObject;

	public GameObject timerObject;

	public WinningsDisplayLayer winningsDisplay;

	public GameObject loadingText;

	public GameObject noInternetText;

	public UIWidget scrollPadding;

	private int activeTabId;

	private LeaderboardsAdapter cachedLead;

	private DateTime compEnd = new DateTime(0L);

	private List<LeaderboardsButton> tabButtons = new List<LeaderboardsButton>();

	private List<LeaderboardEntry> leadItems = new List<LeaderboardEntry>();

	private List<LeaderboardSegmentedPrizeEntry> prizeItems = new List<LeaderboardSegmentedPrizeEntry>();

	private List<GameObject> emptyEntries = new List<GameObject>();

	private GameObject playerItem;

	private GameObject activeAlignmentObject;

	private bool isPlayerInit;

	public EntriesBehindPlayer behindPlayer;

	private bool shouldAlignInUpdate;

	private void OnEnable()
	{
		Ads.instance.hideBanner(true);
		UITable component = leadTable.GetComponent<UITable>();
		if (component != null)
		{
			component.onReposition = OnReposition;
		}
		TableTennisMainNavigation instance = TableTennisMainNavigation.instance;
		instance.SetHeader(TableTennisMainNavigation.HeaderType.None);
		Debug.Log("enabling leaderboards");
		EnableNoConnectionText(false);
		if (cachedLead == null)
		{
			if (!GGSupportMenu.instance.isNetworkConnected())
			{
				EnableNoConnectionText(true);
				return;
			}
			SetLoading();
			FetchLeaderboard();
		}
		else if (cachedLead.leaderboards.Count > 0 && !cachedLead.leaderboards[activeTabId].isEmpty)
		{
			UITools.AlignToLeftOnScroll(tabButtons[0].gameObject.GetComponent<UIWidget>(), tabView, 85f);
			UIWidget uIWidget = ((prizeItems.Count <= 0 || !prizeItems[0].gameObject.activeSelf) ? leadItems[0].GetComponent<UIWidget>() : prizeItems[0].GetComponent<UIWidget>());
			AlignOnScroll();
		}
	}

	private void EnableNoConnectionText(bool visible)
	{
		if (noInternetText != null)
		{
			noInternetText.SetActive(visible);
		}
		if (visible)
		{
			TableTennisDialog.instance.ShowOk("No Internet Connection", "You need to be connected to Internet for leaderboards. Please connect to internet and try again", "Ok", delegate
			{
				NavigationManager.instance.Pop();
				NavigationManager.instance.Pop();
			});
		}
	}

	private void OnDisable()
	{
		Debug.Log(" Removing cached lead ");
		cachedLead = null;
		TableTennisMainNavigation instance = TableTennisMainNavigation.instance;
		if (!isPlayerInit)
		{
			UnityEngine.Object.Destroy(playerItem);
		}
		playerItem = null;
		HideAll();
		foreach (LeaderboardsButton tabButton in tabButtons)
		{
			tabButton.gameObject.SetActive(false);
		}
	}

	private void HideInvisibleWidgets()
	{
		UIPanel component = leadView.GetComponent<UIPanel>();
		if (prizeItems.Count > 0 && !loadingText.activeSelf)
		{
			foreach (LeaderboardSegmentedPrizeEntry prizeItem in prizeItems)
			{
				prizeItem.gameObject.SetActive(false);
				prizeItem.gameObject.SetActive(component.IsVisible(prizeItem.GetComponent<UIWidget>()));
			}
		}
		if (leadItems.Count > 0 && !loadingText.activeSelf)
		{
			foreach (LeaderboardEntry leadItem in leadItems)
			{
				leadItem.gameObject.SetActive(false);
				leadItem.gameObject.SetActive(component.IsVisible(leadItem.GetComponent<UIWidget>()));
			}
		}
		if (emptyEntries.Count <= 0 || loadingText.activeSelf)
		{
			return;
		}
		foreach (GameObject emptyEntry in emptyEntries)
		{
			emptyEntry.gameObject.SetActive(false);
			emptyEntry.gameObject.SetActive(component.IsVisible(emptyEntry.GetComponent<UIWidget>()));
		}
	}

	private void Update()
	{
		if (shouldAlignInUpdate)
		{
			UIWidget target = ((prizeItems.Count <= 0 || !prizeItems[0].gameObject.activeSelf) ? leadItems[0].GetComponent<UIWidget>() : prizeItems[0].GetComponent<UIWidget>());
			if (playerItem != null && playerItem.GetComponent<UIWidget>() != null)
			{
				Debug.Log("Active alignment object " + playerItem.name);
				UITools.CenterOnScroll(playerItem.transform, leadView);
			}
			else
			{
				UITools.AlignToTopOnScroll(target, leadView, 10f);
			}
			shouldAlignInUpdate = false;
		}
		UpdateTimer();
		if (!(playerItem == null) && playerItem.transform.position.y < activeAlignmentObject.transform.position.y && !leadEntryObject.activeSelf && !leadEntryUnavailableObject.activeSelf)
		{
			GeneratePlayerStats();
		}
	}

	public void LeaderboardReceived(GGServerRequestsBackend.ServerRequest request)
	{
		cachedLead = null;
		if (request.status == GGServerRequestsBackend.ServerRequest.RequestStatus.Success)
		{
			GGServerRequestsBackend.LeaderboardsRequest leaderboardsRequest = request as GGServerRequestsBackend.LeaderboardsRequest;
			GGServerRequestsBackend.SegmentedLeaderboardsRequest segmentedLeaderboardsRequest = request as GGServerRequestsBackend.SegmentedLeaderboardsRequest;
			if (leaderboardsRequest != null)
			{
				cachedLead = new LeaderboardsAdapter(request.GetResponse<Lead>());
			}
			if (segmentedLeaderboardsRequest != null)
			{
				cachedLead = new LeaderboardsAdapter(request.GetResponse<CombinationLeads>());
			}
		}
		UITools.SetActive(loadingText, false);
		InitLeaderboards();
	}

	public void LeaderboardSet(LeaderboardsAdapter lead)
	{
		cachedLead = lead;
		InitLeaderboards();
	}

	public void OnTabButtonClick(int newActiveTabId)
	{
		tabButtons[activeTabId].Deactivate();
		activeTabId = newActiveTabId;
		GenerateLeaderboard();
		GeneratePlayerStats();
		UpdatePrizes();
		UpdateLeagueName();
		if (winningsDisplay != null)
		{
			UpdateWinnings();
		}
	}

	private void FetchLeaderboard()
	{
		if (dataProvider == DataProvider.NonSegmented)
		{
			GGServerRequestsBackend.LeaderboardsRequest lead = new GGServerRequestsBackend.LeaderboardsRequest(GGPlayerSettings.instance.Level(), GameConstants.Instance.CountryForFlag(GGPlayerSettings.instance.Model.flag).countryName.ToLower());
			BehaviourSingletonInit<GGServerRequestsBackend>.instance.GetCompetitionLeaderboards(lead, LeaderboardReceived);
		}
		else if (dataProvider == DataProvider.Segmented)
		{
			GGServerRequestsBackend.SegmentedLeaderboardsRequest lead2 = new GGServerRequestsBackend.SegmentedLeaderboardsRequest(GGPlayerSettings.instance.Level(), GameConstants.Instance.CountryForFlag(GGPlayerSettings.instance.Model.flag).countryName.ToLower());
			BehaviourSingletonInit<GGServerRequestsBackend>.instance.GetSegmentedCompetitionLeaderboards(lead2, LeaderboardReceived);
		}
		else
		{
			OnTestLeaderboardReceived();
		}
	}

	public void OnTestLeaderboardReceived()
	{
		cachedLead = LeaderboardsAdapter.CreateTestSegmentedLeaderboard();
		loadingText.SetActive(false);
		InitLeaderboards();
	}

	private void InitLeaderboards()
	{
		if (cachedLead == null)
		{
			cachedLead = new LeaderboardsAdapter(new CombinationLeads());
		}
		compEnd = GGServerRequestsBackend.GetDateTimeCompEnd(cachedLead.compEndTimestamp);
		if (activeTabId >= cachedLead.leaderboards.Count)
		{
			activeTabId = 0;
		}
		GenerateTabButtons();
		GenerateLeaderboard();
		GeneratePlayerStats();
		UpdatePrizes();
		UpdateLeagueName();
		if (winningsDisplay != null)
		{
			UpdateWinnings();
		}
		UpdateTimer();
	}

	private void GenerateTabButtons()
	{
		int count = cachedLead.leaderboards.Count;
		for (int i = 0; i < count; i++)
		{
			if (i >= tabButtons.Count)
			{
				GameObject gameObject = NGUITools.AddChild(tabTable.gameObject, tabPrefab);
				gameObject.name = i.ToString();
				tabButtons.Add(gameObject.GetComponent<LeaderboardsButton>());
			}
			tabButtons[i].gameObject.SetActive(true);
			tabButtons[i].InitButton(cachedLead.leaderboards[i].name, i, i == activeTabId);
		}
		for (int j = count; j < tabButtons.Count; j++)
		{
			tabButtons[j].gameObject.SetActive(false);
		}
		tabTable.Reposition();
		if (count > 0)
		{
			UITools.AlignToLeftOnScroll(tabButtons[0].gameObject.GetComponent<UIWidget>(), tabView, 2f);
		}
	}

	private void AlignOnScroll()
	{
		UIWidget target = ((prizeItems.Count <= 0 || !prizeItems[0].gameObject.activeSelf) ? leadItems[0].GetComponent<UIWidget>() : prizeItems[0].GetComponent<UIWidget>());
		if (playerItem != null && playerItem.GetComponent<UIWidget>() != null)
		{
			StopAllCoroutines();
			StartCoroutine(UITools.DoCenterOnScroll(playerItem.transform, leadView));
		}
		else
		{
			StopAllCoroutines();
			StartCoroutine(UITools.DoAlignToTopOnScroll(target, leadView, 10f));
		}
	}

	private void GenerateLeaderboard()
	{
		if (cachedLead.leaderboards.Count <= 0)
		{
			return;
		}
		if (!isPlayerInit)
		{
			UnityEngine.Object.Destroy(playerItem);
		}
		playerItem = null;
		activeAlignmentObject = null;
		isPlayerInit = false;
		GenerateLeadEntries();
		leadTable.Reposition();
		if (!cachedLead.leaderboards[activeTabId].isEmpty)
		{
			UIWidget uIWidget = ((prizeItems.Count <= 0 || !prizeItems[0].gameObject.activeSelf) ? leadItems[0].GetComponent<UIWidget>() : prizeItems[0].GetComponent<UIWidget>());
			AlignOnScroll();
			UITools.SetActive(loadingText, false);
			return;
		}
		if (playerItem != null)
		{
			UITools.AlignToBottomOnScroll(playerItem.GetComponent<UIWidget>(), leadView, 2f);
		}
		UITools.SetActive(loadingText, true);
		UITools.ChangeText(loadingText.GetComponent<UILabel>(), "Leaderboard Empty");
	}

	private void GenerateLeadEntries(string playerId, Lead.Leaderboard leaderboard)
	{
		int count = leaderboard.rankings.Count;
		int prevLeadEntryIndex = -1;
		int num = 0;
		int num2 = 0;
		for (int i = 0; i < count; i++)
		{
			if (HasEntryIndexDiscontinuity(prevLeadEntryIndex, leaderboard.rankings[i].leaderboardIndex))
			{
				AddEmptyEntry(num, num2);
				num2++;
				num++;
			}
			prevLeadEntryIndex = leaderboard.rankings[i].leaderboardIndex;
			AddLeadEntry(i, playerId, num2, leaderboard.rankings[i]);
			num2++;
		}
		UITable component = leadTable.GetComponent<UITable>();
		UIWidget uIWidget = null;
		UIWidget uIWidget2 = null;
		foreach (Transform child in component.children)
		{
			UIWidget component2 = child.GetComponent<UIWidget>();
			if (component2.cachedGameObject.activeSelf)
			{
				if (uIWidget == null)
				{
					uIWidget = component2;
				}
				uIWidget2 = component2;
			}
		}
		HideUnusedEntries(num, leaderboard);
		if (!isPlayerInit)
		{
			AddEntryUnavailable(num2);
			num2++;
		}
		int num3 = 0;
		if (leaderboard.rankings.Count > 0)
		{
			num3 = leaderboard.rankings[count - 1].leaderboardIndex;
		}
		int entriesBehindCount = Mathf.Max(0, leaderboard.totalInLead - (num3 + 1));
		if (ShouldAddCountBehindPlayer(entriesBehindCount))
		{
			AddEntriesBehindPlayerCount(entriesBehindCount, num2);
			num2++;
		}
		else
		{
			UITools.SetActive(behindPlayer, false);
		}
	}

	private Color GetColorForPrizeBck(int index)
	{
		return ScriptableObjectSingleton<SettingsUI>.instance.GetColorForPrize(index).colorBck;
	}

	private Color GetColorForPrizeFront(int index)
	{
		return ScriptableObjectSingleton<SettingsUI>.instance.GetColorForPrize(index).colorFront;
	}

	private void AddPrizeEntry(int prizeEntryCount, int nameCount, Lead.SegmentedLeaderboard.RankRange rankRange)
	{
		List<LeaderboardSegmentedPrizeEntry> list = prizeItems;
		Color colorForPrizeBck = GetColorForPrizeBck(prizeEntryCount);
		Color colorForPrizeFront = GetColorForPrizeFront(prizeEntryCount);
		if (prizeEntryCount >= list.Count)
		{
			GameObject gameObject = NGUITools.AddChild(leadTable.gameObject, prizeItemPrefab);
			list.Add(gameObject.GetComponent<LeaderboardSegmentedPrizeEntry>());
		}
		LeaderboardSegmentedPrizeEntry leaderboardSegmentedPrizeEntry = list[prizeEntryCount];
		leaderboardSegmentedPrizeEntry.gameObject.SetActive(true);
		leaderboardSegmentedPrizeEntry.gameObject.name = nameCount.ToString("D8");
		leaderboardSegmentedPrizeEntry.Init(rankRange, colorForPrizeBck, colorForPrizeFront);
	}

	private void GenerateLeadEntries(string playerId, LeaderboardsAdapter.SingleSegmentedLeaderboard segmented)
	{
		Lead.SegmentedLeaderboard leaderboard = segmented.leaderboard;
		GGDebug.Log("GENERATE SEGMENTED");
		int num = -1;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		int num5 = 0;
		HideAll();
		Color activeColor = Color.white;
		Color white = Color.white;
		foreach (Lead.SegmentedLeaderboard.RankRange item in leaderboard.rankRange)
		{
			GGDebug.Log("Rank Range Players " + item.players.Count);
			if (item.players == null || item.players.Count == 0)
			{
				continue;
			}
			if (item.prizes != null)
			{
				activeColor = GetColorForPrizeBck(num4);
				white = GetColorForPrizeFront(num4);
				AddPrizeEntry(num4, num3, item);
				num4++;
				num3++;
			}
			foreach (Lead.Leaderboard.Ranking player in item.players)
			{
				AddLeadEntry(num5, playerId, num3, player, activeColor);
				num5++;
				num3++;
			}
		}
		UITable component = leadTable.GetComponent<UITable>();
		component.Reposition();
	}

	private void OnReposition()
	{
	}

	private void GenerateLeadEntries()
	{
		string playerId = ((cachedLead.leaderboards[activeTabId].player == null) ? string.Empty : cachedLead.leaderboards[activeTabId].player.playerId);
		LeaderboardsAdapter.SingleLeaderboardAdapter singleLeaderboardAdapter = cachedLead.leaderboards[activeTabId];
		LeaderboardsAdapter.SingleNonSegmentedLeaderboard singleNonSegmentedLeaderboard = singleLeaderboardAdapter as LeaderboardsAdapter.SingleNonSegmentedLeaderboard;
		LeaderboardsAdapter.SingleSegmentedLeaderboard singleSegmentedLeaderboard = singleLeaderboardAdapter as LeaderboardsAdapter.SingleSegmentedLeaderboard;
		if (singleNonSegmentedLeaderboard != null)
		{
			GenerateLeadEntries(playerId, singleNonSegmentedLeaderboard.leaderboard);
		}
		if (singleSegmentedLeaderboard != null)
		{
			GenerateLeadEntries(playerId, singleSegmentedLeaderboard);
		}
	}

	private bool HasEntryIndexDiscontinuity(int prevLeadEntryIndex, int nextLeadEntryIndex)
	{
		return prevLeadEntryIndex != -1 && prevLeadEntryIndex + 1 != nextLeadEntryIndex;
	}

	private void AddEmptyEntry(int activeEmptyEntry, int nameCount)
	{
		if (activeEmptyEntry >= emptyEntries.Count)
		{
			GameObject item = NGUITools.AddChild(leadTable.gameObject, emptyEntryPrefab);
			emptyEntries.Add(item);
		}
		emptyEntries[activeEmptyEntry].SetActive(true);
		emptyEntries[activeEmptyEntry].name = nameCount.ToString("D8");
	}

	private void AddLeadEntry(int leadItemIndex, string playerId, int nameCount, Lead.Leaderboard.Ranking ranking)
	{
		AddLeadEntry(leadItemIndex, playerId, nameCount, ranking, Color.white);
	}

	private void AddLeadEntry(int leadItemIndex, string playerId, int nameCount, Lead.Leaderboard.Ranking ranking, Color activeColor)
	{
		if (leadItemIndex >= leadItems.Count)
		{
			GameObject gameObject = NGUITools.AddChild(leadTable.gameObject, leadItemPrefab);
			leadItems.Add(gameObject.GetComponent<LeaderboardEntry>());
		}
		leadItems[leadItemIndex].gameObject.SetActive(true);
		bool flag = playerId == ranking.playerId;
		leadItems[leadItemIndex].InitEntry(ranking, flag, activeColor);
		if (flag)
		{
			playerItem = leadItems[leadItemIndex].gameObject;
			activeAlignmentObject = leadEntryObject;
			isPlayerInit = true;
		}
		leadItems[leadItemIndex].gameObject.name = nameCount.ToString("D8");
	}

	private void HideAll()
	{
		foreach (LeaderboardEntry leadItem in leadItems)
		{
			leadItem.gameObject.SetActive(false);
		}
		foreach (GameObject emptyEntry in emptyEntries)
		{
			emptyEntry.gameObject.SetActive(false);
		}
		foreach (LeaderboardSegmentedPrizeEntry prizeItem in prizeItems)
		{
			prizeItem.gameObject.SetActive(false);
		}
	}

	private void HideUnusedEntries(int activeEmptyEntry, Lead.Leaderboard leaderboard)
	{
		int count = leaderboard.rankings.Count;
		for (int i = count; i < leadItems.Count; i++)
		{
			leadItems[i].gameObject.SetActive(false);
		}
		for (int j = activeEmptyEntry; j < emptyEntries.Count; j++)
		{
			emptyEntries[j].SetActive(false);
		}
		foreach (LeaderboardSegmentedPrizeEntry prizeItem in prizeItems)
		{
			prizeItem.gameObject.SetActive(false);
		}
	}

	private void AddEntryUnavailable(int nameCount)
	{
		playerItem = NGUITools.AddChild(leadTable.gameObject, playerEntryEmptyPrefab);
		playerItem.SetActive(true);
		playerItem.name = nameCount.ToString("D8");
		activeAlignmentObject = leadEntryUnavailableObject;
	}

	private bool ShouldAddCountBehindPlayer(int entriesBehindCount)
	{
		if (cachedLead.leaderboards[activeTabId].isEmpty)
		{
			return false;
		}
		if (cachedLead.leaderboards[activeTabId].player == null || cachedLead.leaderboards[activeTabId].player.leaderboardIndex < 0)
		{
			return false;
		}
		if (entriesBehindCount == 0)
		{
			return false;
		}
		return true;
	}

	private void AddEntriesBehindPlayerCount(int entriesBehindCount, int nameCount)
	{
		if (!(behindPlayer == null))
		{
			behindPlayer.ChangeText(entriesBehindCount + " more players");
			UITools.SetActive(behindPlayer, true);
			behindPlayer.gameObject.name = nameCount.ToString("D8");
		}
	}

	private void GeneratePlayerStats()
	{
		if (cachedLead.leaderboards.Count > 0 && cachedLead.leaderboards[activeTabId].isPlayerRanked)
		{
			leadEntryUnavailableObject.SetActive(false);
			leadEntryObject.SetActive(true);
			Lead.Leaderboard.Ranking player = cachedLead.leaderboards[activeTabId].player;
			GGDebug.Log("Lead entry init " + player.name + " index " + player.leaderboardIndex);
			playerEntry.InitEntry(player, true, Color.white);
		}
		else
		{
			leadEntryObject.SetActive(false);
			leadEntryUnavailableObject.SetActive(true);
		}
	}

	private void UpdatePrizes()
	{
		if (cachedLead.leaderboards.Count > 0 && cachedLead.leaderboards[activeTabId].prizes.Count >= 3)
		{
			UITools.SetActive(prizesGameObject, true);
			if (cachedLead.leaderboards[activeTabId].prizes[0].coins > 0)
			{
				DisplayCoins();
			}
			else
			{
				DisplayCash();
			}
		}
		else
		{
			UITools.SetActive(prizesGameObject, false);
			UITools.ChangeText(prizeFirst, "0");
			UITools.ChangeText(prizeSecond, "0");
			UITools.ChangeText(prizeThird, "0");
		}
	}

	private void DisplayCoins()
	{
		UITools.ChangeText(prizeFirst, GGFormat.FormatWinnings(cachedLead.leaderboards[activeTabId].prizes[0].coins));
		UITools.ChangeText(prizeSecond, GGFormat.FormatWinnings(cachedLead.leaderboards[activeTabId].prizes[1].coins));
		UITools.ChangeText(prizeThird, GGFormat.FormatWinnings(cachedLead.leaderboards[activeTabId].prizes[2].coins));
		UITools.ChangeSprite(WinCurrency, "money 4");
	}

	private void DisplayCash()
	{
		UITools.ChangeText(prizeFirst, GGFormat.FormatWinnings(cachedLead.leaderboards[activeTabId].prizes[0].cash));
		UITools.ChangeText(prizeSecond, GGFormat.FormatWinnings(cachedLead.leaderboards[activeTabId].prizes[1].cash));
		UITools.ChangeText(prizeThird, GGFormat.FormatWinnings(cachedLead.leaderboards[activeTabId].prizes[2].cash));
		UITools.ChangeSprite(WinCurrency, "money 7");
	}

	private void UpdateLeagueName()
	{
		if (cachedLead.leaderboards.Count > 0)
		{
			UITools.ChangeText(leagueNameLabel, cachedLead.leaderboards[activeTabId].name + " League");
			timerObject.SetActive(true);
		}
		else
		{
			UITools.ChangeText(leagueNameLabel, "League Unavailable");
			timerObject.SetActive(false);
		}
	}

	private void UpdateTimer()
	{
		DateTime now = DateTime.Now;
		string text = "--h --m --s";
		if (compEnd != new DateTime(0L))
		{
			text = string.Empty;
			if (!(compEnd > now))
			{
				UITools.ChangeText(timerLabel, "Competition ended");
				return;
			}
			TimeSpan span = compEnd.Subtract(now);
			text = GGFormat.FormatTimeSpanHuman(span);
		}
		UITools.ChangeText(timerLabel, "Ends in: " + text);
	}

	private void UpdateWinnings()
	{
		if (cachedLead.leaderboards.Count > 0)
		{
			winningsDisplay.UpdateWinnings(cachedLead.leaderboards[activeTabId].winnings);
			winningsDisplay.gameObject.SetActive(true);
		}
		else
		{
			winningsDisplay.gameObject.SetActive(false);
		}
	}

	private void SetLoading()
	{
		leadEntryObject.SetActive(false);
		leadEntryUnavailableObject.SetActive(false);
		loadingText.SetActive(true);
		UITools.ChangeText(loadingText.GetComponent<UILabel>(), "Loading...");
		UITools.ChangeText(leagueNameLabel, "League Loading");
		timerObject.SetActive(false);
		UITools.ChangeText(prizeFirst, "0");
		UITools.ChangeText(prizeSecond, "0");
		UITools.ChangeText(prizeThird, "0");
	}

	public void ShowInfo()
	{
		string text = "- Ranking is based on total weekly token winnings\n- Rematch winnings do not count towards the total weekly token winnings\n- Open the app at the end of the week to check if you won a prize!";
		TableTennisDialog.instance.ShowOk("Leaderboard Info", text, "Ok", null);
	}
}
